package com.sinoglobal.dumping.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sinoglobal.dumping.R;
import com.sinoglobal.dumping.bean.Dumpling_ReceivedCardVo;
import com.sinoglobal.dumping.util.Dumpling_TimeUtils;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/2/18.
 */
public class Dumpling_ReceivedCardAdapter extends BaseAdapter {
    private Context mContext;

    public ArrayList<Dumpling_ReceivedCardVo> getCardList() {
        return cardList;
    }

    private ArrayList<Dumpling_ReceivedCardVo> cardList;

    public Dumpling_ReceivedCardAdapter(ArrayList<Dumpling_ReceivedCardVo> list,Context context) {
        mContext=context;
        cardList=list;
    }

    @Override
    public int getCount() {
        return cardList.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
       ViewHolder viewHolder;
        if (view==null) {
            viewHolder=new ViewHolder();
            view=View.inflate(mContext, R.layout.dumpling_received_card_list_item,null);
            viewHolder.receivedCardDate= (TextView) view.findViewById(R.id.dumpling_received_card_time);
            viewHolder.receivedCardPhone= (TextView) view.findViewById(R.id.dumpling_received_card_phone);
            view.setTag(viewHolder);
        } else {
            viewHolder= (ViewHolder) view.getTag();
        }
        viewHolder.receivedCardPhone.setText(cardList.get(i).getInfo());
        viewHolder.receivedCardDate.setText(Dumpling_TimeUtils.parseTimestampToString("" + cardList.get(i).getCreateDate()));
        return view;
    }
    class ViewHolder{
        public TextView receivedCardDate;
        public TextView receivedCardPhone;
    }
}
